<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>Login</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="css/bootstrap.min.css" />
		<link rel="stylesheet" href="css/index.css" />
		<link rel="stylesheet" href="css/style.css" />
		<link rel="stylesheet" href="css/form-elements.css" />
		<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
	</head>

	<body style="height: 875px;">
    <% include header.ejs%>
		<!-- Top content -->
		<div class="top-content">
			<div class="inner-bg">
				<div class="container">
					<div class="row login-title">
						<div class="col-sm-8 col-sm-offset-2 text">
							<h1><strong>学生档案管理系统    </strong>登录页面</h1>
							<div class="description">
								<p>
									<!--这是基于用户端的登录页面-->
								</p>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-sm-6 col-sm-offset-3 form-box">
							<div class="form-top">
								<div class="form-top-left">
									<h3>登录</h3>
									<p>请输入您的用户名和密码登录</p>
								</div>
								<div class="form-top-right">
									<i class="fa fa-key"></i>
								</div>
							</div>
							<div class="form-bottom">
								<form role="form" action="" method="post" class="login-form">
									<div class="form-group">
										<label class="sr-only" for="form-username">用户名</label>
										<input type="text" id="dengluming"  name="form-username" placeholder="请输入用户名..." class="form-username form-control" id="form-username">
									</div>
									<div class="form-group">
										<label class="sr-only" for="form-password">密码</label>
										<input type="password" id="mima" name="form-password" placeholder="请输入您的密码..." class="form-password form-control" id="form-password">
									</div>
									<div class="form-group" id="loginStyle">
                                        <div class="radio col-sm-4" style="margin-top: -5px">
                                        <label>
                                            <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
                                            管理员
                                        </label>
                                    </div>
                                    <div class="radio col-sm-4">
                                        <label>
                                            <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
                                            教师
                                        </label>
                                    </div>
                                    <div class="radio col-sm-4">
                                        <label>
                                            <input type="radio" name="optionsRadios" id="optionsRadios3" value="option3">
                                             学生
                                        </label>
                                    </div>
									</div>
									<button   id="denglu" type="button" class="btn">登录</button>
									<div class="alert alert-danger" role="alert" id="cuowukuang" style="display: none">
										密码不正确
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="container summary">
				<footer>
					<p class="pull-right">
						<a href="#top">回到顶部</a>
					</p>
					<p class="pull-left">&copy; 学生档案管理系统</p>
				</footer>
			</div>
		</div>
		<script type="text/javascript">

            $("input").focus(function(){
                $("#cuowukuang").fadeOut();
            });
            //用ajax提交表单
            $("#denglu").click(function(){
                //获取radio值
                var selectedRadio=$('#loginStyle input:radio:checked').val();
//                alert(selectedRadio);
                $.post("/dologin",{
                    "dengluming" : $("#dengluming").val(),
                    "mima" : $("#mima").val(),
                    "loginStyle":selectedRadio
                },function(result){
                    if(result == "1000"){
                        alert("管理员登录成功！将自动跳转到后台管理页面");
                        window.location = "/managePage";
                    }else if(result == "-2"){
                        $("#cuowukuang").fadeIn();
                        $("#cuowukuang").html("该用户没有注册！");
                    }else if(result == "-1"){
                        $("#cuowukuang").fadeIn();
                        $("#cuowukuang").html("密码不正确");
                    }else if(result=="1001"){
                        alert("教师登录成功！将自动跳转到主页");
                        window.location = "/teacherIndex";
                    }else if(result=='1'){
                        alert("学生登录成功！将自动跳转到主页");
                        window.location="/";
                    }
                })
            });
		</script>

	</body>

</html>